package lib.persistence.commands;

import global.ConfigData;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * Handles the creation of the PRS database
 * @author jon
 *
 */
public class SetupDatabase extends CommandAbstract 
{
	
	private Connection conn;

	public SetupDatabase(Connection conn)
	{
		this.conn = conn;
		
	}
	/**
	 * Create all the tables for PRS to function
	 * @throws SQLException 
	 */
	public void execute() throws SQLException
	{
		CreateTable ct = new CreateTable();
		ct.CreateMySqlTable(conn, CreateTable.getEventFields(), ConfigData.EVENT_TABLE);
		ct.CreateMySqlTable(conn, CreateTable.getMilestoneFields(), ConfigData.MILESTONE_TABLE);
		ct.CreateMySqlTable(conn, CreateTable.getProjectFields(), ConfigData.PROJECT_TABLE);
		ct.CreateMySqlTable(conn, CreateTable.getProjectPersonFields(), ConfigData.PROJECT_PERSON_TABLE);
		ct.CreateMySqlTable(conn, CreateTable.getPersonFields(), ConfigData.PERSON_TABLE);
		ct.CreateMySqlTable(conn, CreateTable.getDeliverableFields(), ConfigData.DELIVERABLE_TABLE);
		ct.CreateMySqlTable(conn, CreateTable.getPublicationFields(), ConfigData.PUBLICATION_TABLE);
		
	}
}
